<template>
  <g-details :detailData="inputData" :inputConfig="inputConfig" :rules="rules" @pop="setdata" ref="detail"> </g-details>
</template>

<script>
import baseMixin from '@/mixins/BaseMixin'
export default {
  name: 'dispatchDetails',
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object
    }
  },
  data() {
    return {
      rules: {
        // deliveryDeptName: [
        //   { required: true, message: this.$selectPlease('model.deliveryDept'), trigger: "blur" },
        // ],
        // materialType:[
        //   { required: true, message: this.$selectPlease('model.materialType'), trigger: "blur" },
        // ],
        // deliveryType:[
        //   { required: true, message: this.$selectPlease('model.deliveryType'), trigger: "blur" },
        // ],
      }
    }
  },
  computed: {
    inputConfig() {
      return [
        {
          type: 'input',
          label: this.$t('out.palletkey'),
          props: 'palletkey',
          disabled: true
        },
        {
          type: 'input',
          label: this.$t('in.standardlpn'),
          props: 'lpn',
          disabled: true
        },
        {
          type: 'input',
          label: this.$t('ex.middloc'),
          props: 'middloc',
          disabled: true
        },
        {
          type: 'input',
          label: this.$t('outbound.fromloc'),
          props: 'fromloc',
          break: true,
          disabled: true
        },
        {
          type: 'input',
          label: this.$t('config.toLoc'),
          props: 'toloc',
          disabled: true
        },
        {
          type: 'select',
          label: this.$t('ex.palletstatus'),
          props: 'palletstatus',
          options: this.getOptions('/codeLookup/RTXPALSTATUS'),
          disabled: true
        },
        {
          type: 'select',
          label: this.$t('ex.pallettype'),
          props: 'pallettype',
          disabled: true,
          options: this.getOptions('codelkup/RTXPALTYPE'),
          break: true
        }
      ]
    }
  },
  methods: {
    setdata(data, close, prop) {
      if (prop == 'deliveryDeptName') {
        this.inputData.deliveryDeptName = data.deptName
        this.inputData.deliveryDeptId = data.id
        const index = this.inputConfig.findIndex(
          item => item.props == 'deliveryMklineNo'
        )
        this.inputConfig[
          index
        ].url = `/baFactoryDeptLine/selectBaFactoryDeptLineList/${data.id}`
      } else if (prop == 'deliveryMklineNo') {
        this.inputData.deliveryDeptName = data.deptName
        this.inputData.deliveryDeptId = data.deptId
        this.inputData.deliveryMklineNo = data.deptLineNo
        this.inputData.deliveryMklineName = data.deptLineName
      }
      close(false)
    },
    validate() {
      return this.$refs.detail.$refs.from.validate()
    }
  },
  mounted() {}
}
</script>

<style scoped>
</style>
